﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.OleDb;
using System.IO;

namespace DAO
{
    public class BoKetNoiCSDL
    {
        public static OleDbConnection KetNoi()
        {
            if (File.Exists("../../Setting.dat"))
            {
                StreamReader sr = new StreamReader("../../Setting.dat");
                string provider = sr.ReadLine().Trim();
                string dataSource = sr.ReadLine().Trim();

                string cnnString = string.Format("Provider={0};Data Source={1}", provider, dataSource);
                OleDbConnection cnn = new OleDbConnection(cnnString);
                cnn.Open();
                return cnn;
            }
            else
            {
                throw new Exception("Không tìm thấy file Setting.dat");
            }
        }
    }
}
